package com.hall.item.item.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.hall.item.item.constans.MqConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MqConfig {

    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange(MqConstants.HMALL_EXCHANGE, true, false);
    }

    @Bean
    public org.springframework.amqp.core.Queue insertQueue() {
        return new org.springframework.amqp.core.Queue(MqConstants.HMALL_INSERT_QUEUE, true);
    }

    @Bean
    public org.springframework.amqp.core.Queue deleteQueue() {
        return new Queue(MqConstants.HMALL_DELETE_QUEUE, true);
    }

    @Bean
    public Binding insertQueueBinding() {
        return BindingBuilder.bind(insertQueue()).to(topicExchange()).with(MqConstants.HMALL_INSERT_KEY);
    }

    @Bean
    public Binding deleteQueueBinding() {
        return BindingBuilder.bind(deleteQueue()).to(topicExchange()).with(MqConstants.HMALL_DELETE_KEY);
    }
}
